import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-07-04
 * Time: 16:13
 */
public class Test25 {
    public static class ListNode {
        int val;
        ListNode next;

        ListNode(int val) {
            this.val = val;
            next = null;
        }

    }

    public static boolean isCycle(ListNode head) {
        ListNode fast = head;
        ListNode slow = head;

        while(fast != null && fast.next != null) {
            fast = fast.next.next;
            slow = slow.next;
            if(fast == slow) {
                return true;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ListNode head = null, tail = null;
        int n = sc.nextInt();
        for(int i = 0; i < n; i++) {
            int val = sc.nextInt();
            ListNode node = new ListNode(val);
            if(head == null) {
                head = node;
            } else {
                tail.next = node;
            }
            tail = node;
        }
        // 连接点
        int pos = sc.nextInt();
        ListNode node = head;
        for(int i = 0; i < pos; i++) {
            node = node.next;
        }
        tail.next = node;
        boolean ret = isCycle(head);
        if(pos == -1) {
            ret = false;
        }
        System.out.println("该链表是否为环形链表："+ret);
    }
}

